﻿/*
 *  谢云：基于extjs的desktop例子，建立ePos的desktop内容
    POS系统的所有界面的入口，并提供基本的操作桌面
 */


MyDesktop = new Ext.app.App({
	init :function(){
		Ext.QuickTips.init();
		//this.guiFactory = normal.guiFactory; //由特定的商店去配置
	},

	getModules : function(){
		return [
            new MyDesktop.InventoryForm(),
            new MyDesktop.CategoryForm()
    	];
	},

    // config for the start menu
    getStartConfig : function(){
        return {
            title: 'ePOS',
            iconCls: 'user',
            toolItems: [{
                text:'Settings',
                iconCls:'settings',
                scope:this
            },'-',{
                text:'Logout',
                iconCls:'logout',
                scope:this
            }]
        };
    }
});

/*商品信息管理
*/
MyDesktop.InventoryForm = Ext.extend(Ext.app.Module,{
    id:'inventory-form',
    init:function(){
        this.launcher = {
            text: '商品信息管理',
            iconcls: 'icon-inventory',
            handler:this.createWindow,
            scope: this
        }
    },
    createWindow: function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow(this.id);
        if(!win){
            win = desktop.createWindow({
                id: 'inventory-form',
                title:'商品信息管理',
                width:740,
                height:480
            }, ePOS.common.storage.MainWin
            );
        }
        win.show();
    }
});
/*
 * 分类信息管理
*/
MyDesktop.CategoryForm = Ext.extend(Ext.app.Module,{
    id:'category-form',
    init:function(){
        this.launcher = {
            text: '分类信息管理',
            iconcls: 'icon-category',
            handler:this.createWindow,
            scope: this
        }
    },
    createWindow: function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow(this.id);
        if(!win){
            var panel = new ePOS.common.guifactory.DSGridPanel({
	            autoHeight:true,
	            autoWidth:true,
	            mode:'update',
	            dataset:ePOS.dataCenter.dt_set.category.createDataSet({
	                url:'/ePOS/common/listcategoryjson',
	                addupdateUrl:'/ePOS/common/addupdatecategory',
	                deleteUrl:'/ePOS/common/deletecategory'
	                })
	        });
            win = desktop.createWindow({
                id: 'category-form',
                title:'分类信息管理',
                width:740,
                height:480,
                items:[panel]
            });
        }
        win.show();
    }
});







